from heap.slot import Slots


class LocalVars(Slots):
    @staticmethod
    def newLocalVars(maxLocals: int):
        if maxLocals < 0:
            raise ValueError("maxLocals must be non-negative")
        vars = LocalVars()
        vars.makeSlot(maxLocals=maxLocals)
        return vars

    def getThis(self):
        return self.getRef(index=0)

    def getBoolean(self, index: int):
        return self.getInt(index=index) == 1
